package com.huawei.esdk.tp.device.smc;

import java.util.Date;

import javax.xml.datatype.XMLGregorianCalendar;

import com.huawei.esdk.platform.common.SDKResult;
import com.huawei.esdk.platform.common.utils.DateUtils;
import com.huawei.esdk.tp.domain.model.ScheduleConference;
import com.huawei.esdk.tp.southcommu.cxf.gen.ScheduleConfSouth;
import com.huawei.esdk.tp.southcommu.cxf.gen.ScheduleTimeSouth;
import com.huawei.esdk.tp.southcommu.cxf.gen.ScheduledConfParamEx2South;
import com.huawei.esdk.tp.southcommu.cxf.gen.SmcErr2South;

public class Convert {

	public static void convert(ScheduleConference conf, ScheduleConfSouth reqMsg) {
		reqMsg.setNewConf(new ScheduledConfParamEx2South());
		convert(conf, reqMsg.getNewConf());
	}

	public static void convert(ScheduleConference srcConf,
			ScheduledConfParamEx2South dstConf) {
		dstConf.setAccessCode(srcConf.getAccessCode());
		dstConf.setName(srcConf.getName());

		ScheduleTimeSouth tm = new ScheduleTimeSouth();
		convert(srcConf.getBeginTime(), DateUtils.toGregorianCalendarDate(tm.getBeginTime()));
		tm.getDuration().setTimeSpan(String.valueOf(srcConf.getLength()));
		dstConf.setConfTime(tm);
	}

	public static void convert(Date src, XMLGregorianCalendar dst) {

	}

	public static <T> void convert(SDKResult<T> retObj,
			SmcErr2South rst) {
		if (rst.getErrCode() != 0) {
			retObj.setErrCode(rst.getErrCode());
			retObj.setDescription(rst.getDescription());
		}
	}

}
